package com.hjq.fcloud.widget

import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.widget.ImageView
import com.hjq.fcloud.R

/**
 * 入库确认
 */
class StoreConfirmImageView : ImageView {

    companion object {
        const val CONFIRM_FAIL = "9"//确认失败
        const val CONFIRM_SUCCESS = "6"//确认成功
    }

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int
    ) : super(context, attrs, defStyleAttr, defStyleRes)

    /**
     * @param status，流程状态：3待确认6已确认9确认失败
     */
    fun setViewData(status: String? = null) {
        if (!TextUtils.isEmpty(status)) {
            if (status.equals(CONFIRM_FAIL)) {
                setImageResource(R.drawable.ic_confirm_fail)
            } else if (status.equals(CONFIRM_SUCCESS)) {
                setImageResource(R.drawable.ic_confirm_success)
            }
        }
    }

}